// Copyright [2020] <unknown>
#include <bits/stdc++.h>
using namespace std;
// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define dbg(x...) { cerr << "\033[32;1m" << #x << " -> "; err(x); }
void err() { cerr << "\033[39;0m" << endl; }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }
#else
#define dbg(...)
#endif

#define sz(x) ((int)x.size())

typedef long long LL;


const int N = 11;

int a[N];
int n;

vector<string> s;

void dfs(int u) {

    vector<int> em;
    for (int i=0; i<n; ++i) {
        if (a[i] == 0) {
            em.push_back(i);
        }   
    }

    // dbg(u, a[0], a[1], a[2], em.size());

    if (em.size() == 0) {

        static char tmp[N];
        for (int i=0; i<n; ++i) {
            // putchar(a[i] + 'a' - 1);
            tmp[i] = a[i] + 'a' - 1;
        }
        tmp[n] = 0;
        s.push_back(string(tmp));
        return;
    }

    int first = em[0];

    a[first] = u;
    if (em.size() == 1) {
        static char tmp[N];
        for (int i=0; i<n; ++i) {
            // putchar(a[i] + 'a' - 1);
            tmp[i] = a[i] + 'a' - 1;
        }
        tmp[n] = 0;
        s.push_back(string(tmp));
        a[first] = 0;
        return;
    }

    int m = em.size() - 1;
    for (int i=(1<<m)-1; i>=0; --i) {
        for (int j=0; j<m; ++j) {
            if ((i >> j) & 1) {
                a[em[m-j]] = u;
            }
        }
        // dbg(u, i);
        dfs(u+1);
        for (int j=0; j<m; ++j) {
            if ((i >> j) & 1) {
                a[em[m-j]] = 0;
            }
        }
    }


    a[first] = 0;
}

int main(int argc, char const *argv[]) {
    // 
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n;
    dfs(1);
    sort(s.begin(), s.end());
    // cout << s[0] << endl;
    for (const auto &p : s)
        cout << p << endl;
    return 0;
}
